import { http as axios } from './request'

/**
 * 取消支付
 * @param orderNo  支付订单编号
 * @param payType  支付类型(1.微信支付；2.支付宝；3.抖音支付)
 */
export const orderCancel = (orderNo: string, payType: number = 1) => {
	return axios({
		method: 'GET',
		url: '/api/mall/order/cancel',
		params: {
			orderNo,
			payType
		}
	})
}

/**
 * 重新支付
 * @param openId 
 * @param orderId 
 * @param payPlatform  支付平台(1.微信公众号；2.抖音小程序，3.H5,4.微信小程序)
 */
export const anewPay = (openId: string, orderId: string, payPlatform = 4) => {
	return axios({
		method: 'POST',
		url: '/api/mall/order/query/create',
		data: {
			openId,
			orderId,
			payPlatform
		}
	})
}

export interface CreateOrderProps {
	city?: string,
	clientType?: string,
	couponProductIds?: string[],
	name?: string,
	openId?: string,
	payPlatform?: number, //支付平台(1.微信公众号；2.抖音小程序，3.H5，4.微信小程序)
	payType?: number, //支付类型(1.微信支付；2.支付宝；3.抖音支付)
	phone?: string,
	productId?: string,
	productName?: string,
	region?: string,
	schoolStoreId?: string,
	appId?: string
}

//创建订单
export const createOrder = (data: CreateOrderProps) => {
	return axios({
		method: 'POST',
		url: '/api/mall/order/create/wx',
		data
	})
}

//订单列表
export const orderList = (current: number, size = 10) => {
	return axios({
		method: 'GET',
		url: '/api/mall/order/list',
		params: { current, size }
	})
}

//我的报名
export const mySignUp = () => {
	return axios({
		method: 'GET',
		url: '/api/mall/order/signUp/info'
	})
}